package com.dyxy.tms.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetWorkUtils {
	private Context context;
	private ConnectivityManager connectivityManager;
	private void init(){
		connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
	}

	public boolean isNetworkAvailable(Context context){
		this.context = context;
		init();
		NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
		for(int i = 0; i<networkInfo.length; i++){
			if (networkInfo[i].getState() == NetworkInfo.State.CONNECTED)
			{
				return true;
			}
		}
		return false;
	}
}
